<?php
/**
 */
class TriggerSettingsTable extends Doctrine_Table
{
		public function getSettings($user_id,$setting_type)
	{
		$query = new Doctrine_Query();
		$query->select('s.*')
		       ->from('TriggerSettings s')
			   ->where("s.user_id='".$user_id."'")
			   ->where("s.setting_type='".$setting_type."'");
			   //echo $query->getSql();exit;
		 $result = $query->execute(array(),Doctrine::HYDRATE_ARRAY);
		 return $result[0];
	        
	}
	public function updateSettings($id,$action)
	{
			$date=date('Y-m-d H:i:s');
		 $query = new Doctrine_Query();
		$query->update('TriggerSettings s')
			  ->set('s.is_connect',"'$action'")
			  ->set('s.modified_date',"'$date'")
			  ->where("s.id='".$id."'");
		  //echo $query;exit;
		return $query->execute();
	}
	public function addSettings($memid,$setting_type,$action)
	{
		$TriggerSettings = new TriggerSettings();
		$TriggerSettings ->user_id = $memid;
		$TriggerSettings ->setting_type = $setting_type;
		$TriggerSettings ->is_connect = $action;
		$TriggerSettings ->connected_date = date('Y-m-d H:i:s');
		$TriggerSettings ->modified_date = date('Y-m-d H:i:s');
		
        //echo '<pre>';print_r($Expressions);exit;
		$TriggerSettings ->save();
		return $TriggerSettings->id;
	}
}